<?php
/**
 * Created by PhpStorm.
 * User: xin6841414_sanxing
 * Date: 2018/6/14
 * Time: 22:55
 */

namespace App\Modules\Home\Http\Controllers;


use App\Http\Controllers\BasicController;
use App\Modules\Manage\Model\SuccessCaseModel;
use Illuminate\Http\Request;

class SuccessCaseController extends BasicController
{
    public function __construct()
    {
        parent::__construct();
        $this->initTheme('home');
        $this->theme->setTitle('成功案例');
    }

    public function index(Request $request)
    {
        $merge = $request->except('_token');
        $success_case_lists = SuccessCaseModel::select('*')->orderBy('created_at','desc')->paginate(9);
        $data = [
            'merge' => $merge,
          'success_case_lists' => $success_case_lists
        ];
        return $this->theme->scope('home.successCase', $data)->render();
    }
    public function info( $id)
    {
        if(empty($id))
        {
            return redirect()->back()->with(['error'=>'参数错误！']);
        }
        $info = SuccessCaseModel::getSuccessInfoById($id);
        $data = [
          'info' => $info
        ];
        return $this->theme->scope('home.successCaseInfo', $data)->render();
    }
}